// 市场销售 / 老人管理
import r from '@/utils/request'
import { type ListParams, type ListResponseType, type ResponseType } from '../types'

enum API {
    elderlyGet = 'elderly/get',// 获取单条老人信息
    elderlyList = "/elderly/list", // 老人列表
    elderlyAdd = "/elderly/add", // 老人添加
    elderlyUpdate = "/elderly/update", // 老人修改
    elderlyDelete = "/elderly/delete", // 老人删除
    elderlyDeleteAll = "/elderly/deleteAll",//老人批量删除
    elderlyTaskList = 'elderlyTaskList/list' // 我服务的老人
}

// 老人列表需要状态
export const stateList = reactive(['未签约','已预定','已入院','已出院'])
// 老人民族列表
export const nationalityList = reactive(['汉族', '蒙古族', '回族', '藏族', '维吾尔族', '苗族', '彝族', '壮族', '布依族', '朝鲜族', '满族', '侗族', '瑶族', '白族', '土家族', '哈尼族', '哈萨克族', '傣族', '黎族', '僳僳族', '佤族', '畲族', '高山族', '拉祜族', '水族', '东乡族', '纳西族', '景颇族', '柯尔克孜族', '土族', '达斡尔族', '仫佬族', '羌族', '布朗族', '撒拉族', '毛南族', '仡佬族', '锡伯族', '阿昌族', '普米族', '塔吉克族', '怒族', '乌孜别克族', '俄罗斯族', '鄂温克族', '德昂族', '保安族', '裕固族', '京族', '塔塔尔族', '独龙族', '鄂伦春族', '赫哲族', '门巴族', '珞巴族', '基诺族'])
// 与老人关系列表
export const relationList = reactive(['父子', '母子', '父女', '母女', '兄弟', '姐妹', '朋友', '其他'])
// 籍贯/省份
export const provinceList = ['河北省', '山西省', '辽宁省', '吉林省', '黑龙江省', '江苏省', '浙江省', '安徽省', '福建省', '江西省', '山东省', '河南省', '湖北省', '湖南省', '广东省', '海南省', '四川省', '贵州省', '云南省', '陕西省', '甘肃省', '青海省', '台湾省', '内蒙古自治区', '广西壮族自治区', '西藏自治区', '宁夏回族自治区', '新疆维吾尔自治区', '北京市', '天津市', '上海市', '重庆市', '香港特别行政区', '澳门特别行政区']
// 政治面貌
export const politicsList = ['中共党员', '中共预备党员', '共青团员', '民革党员', '民盟盟员', '民建会员', '民进会员', '农工党党员', '致公党党员', '九三学社社员', '台盟盟员', '无党派人士', '群众']
// 学历
export const educationList = ['小学', '初中', '技工学校', '职业高中', '高等职业学校', '中等专业学校', '中等师范学校', '大学专科', '大学本科', '硕士研究生', '博士研究生', '博士后']

export interface ElderlyItem{
    id: number;
}
export function elderlyGetAPI(id:number):Promise<ResponseType<elderlyGetResAPI>> {
    return r.get( API.elderlyGet + '/' + id )
}

export interface elderlyListParams extends ListParams{
    name?: string
    idCard?: string
    begId?: string
    state?:number
    houseId?:number
}

export interface elderlyListResAPI {
    id:             number;
    companyId:      number;
    name:           string;
    mobile:         string;
    photo:          string;
    gender:         number;
    birthday:       string;
    nativePlace:    string;
    nation:         string;
    idCard:         string;
    politics:       string;
    socialCard:     string;
    marriage:       string;
    eduLevel:       string;
    education:      string;
    resident:       string;
    address:        string;
    begId:          number;
    houseId:        number;
    state:          number;
    addTime:        string;
    addAccountId:   number;
    stateName:      string;
    begName:        string;
    addAccountName: string;
    houseName:      string;
    buildingName:   string;
    health:         any;
    selfCares:      any;
    checkups:       any;
    family:         any;
}

export function getelderlyListAPI(Params:elderlyListParams):Promise<ListResponseType<elderlyListResAPI>> {
    return r.get(API.elderlyList,Params)
}
// 添加机修改一样
export interface  elderlyAddAndUpdateParams {
    id:          number;
    name:        string;
    mobile:      string;
    photo:       string;
    gender:      number | string;
    birthday:    string;
    nativePlace: string;
    nation:      string;
    idCard:      string;
    politics:    string;
    socialCard:  string;
    marriage:    string;
    eduLevel:    string;
    education:   string;
    resident:    string;
    address:     string;
    health:      Health;
    selfCares:   SelfCare[];
    checkups:    Checkup[];
    family:      Family[];
}

export interface elderlyAddAndUpdateResAPI {
    id:             number;
    companyId:      number;
    name:           string;
    mobile:         string;
    photo:          string;
    gender:         number;
    birthday:       string;
    nativePlace:    string;
    nation:         string;
    idCard:         string;
    politics:       string;
    socialCard:     string;
    marriage:       string;
    eduLevel:       string;
    education:      string;
    resident:       string;
    address:        string;
    begId:          number;
    houseId:        number;
    state:          number;
    addTime:        string;
    addAccountId:   number;
    stateName:      string;
    begName:        string;
    addAccountName: string;
    houseName:      string;
    buildingName:   string;
    health:         Health;
    selfCares:      Checkup[];
    checkups:       Checkup[];
    family:         Family[];
}

export function elderlyAddAPI(Params:elderlyAddAndUpdateParams):Promise<ResponseType<elderlyAddAndUpdateResAPI>> {
    return r.post(API.elderlyAdd,Params)
}

export function elderlyUpdateAPI(Params:elderlyAddAndUpdateParams):Promise<ResponseType<elderlyAddAndUpdateResAPI>> {
    return r.put(API.elderlyUpdate,Params)
}

export function elderlyDeleteAPI(id:number):Promise<ResponseType<null>> {
    return r.delete(API.elderlyDelete+'/'+id)
}

export function elderlyDeleteAllAPI(ids:number[]):Promise<ResponseType<null>> {
    return r.post(API.elderlyDeleteAll,ids)
}


export interface elderlyGetResAPI {
    id:             number;
    companyId:      number;
    name:           string;
    mobile:         string;
    photo:          string;
    gender:         number;
    birthday:       string;
    nativePlace:    string;
    nation:         string;
    idCard:         string;
    politics:       string;
    socialCard:     string;
    marriage:       string;
    eduLevel:       string;
    education:      string;
    resident:       string;
    address:        string;
    begId:          number;
    houseId:        number;
    state:          number;
    addTime:        string;
    addAccountId:   number;
    stateName:      string;
    begName:        string;
    addAccountName: string;
    houseName:      string;
    buildingName:   string;
    // 病史
    health:         Health;
    // 老人自理情况
    selfCares:      Checkup[];
    // 体检报告
    checkups:       Checkup[];
    // 家人
    family:         Family[];
}


export interface Checkup {
    name:      string;
    picture?:  string;
    val?:      string;
}

export interface Family {
    id:        number;
    elderlyId: number;
    name:      string;
    mobile:    string;
    idCard:    string;
    relation:  string;
    gender?:    number;
    address:   string;
}

export interface Health {
    id?:           number;
    elderlyId?:    number;
    // 既往病史
    oldillness:   string;
    // 现病史
    nowillness:   string;
    // 其他疾病
    otherillness: string;
    // 其他特殊情况说明
    otherCase:    string;
}

export interface SelfCare {
    name: string;
    val:  string;
}